import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

// https://vite.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        api: "modern-compiler" // or 'modern'css报错更新配置代码
      }
    }
  },
  plugins: [vue()],
  server:{
    host: '0.0.0.0', //解决"vite use '--host' to expose"
    port: 8083,
    hmr: true,//编辑代码保存后自动更新
    open: true,//运行项目自动打开网页
    proxy: {
      '/api': {
        target: 'http://localhost:8089',//后端接口地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
    resolve: {
    alias:[
      {
        find: '@',
        replacement: resolve(__dirname, 'src' )
      }
    ]
  },
  define: {
    'process.env': {
          'BASE_API':"http://localhost:8089"
        }
      },
})
